package com.xiaoshuidi.cloud.module.member.enums.point;

import cn.hutool.core.lang.Assert;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;

@Getter
@AllArgsConstructor
public enum PointSendTypeEnum {
    HAND(0, "手动发放"),

    AUTOMATIC(1, "自动"),
    MALL(2, "商城");


    private Integer code;
    private String name;

    public static String getNameByCode(Integer code) {
        PointSendTypeEnum pointSendTypeEnum = Arrays.stream(PointSendTypeEnum.values()).filter(p -> p.code.intValue() == code.intValue()).findFirst().orElse(null);
        Assert.isTrue(pointSendTypeEnum != null, "pointSendTypeEnum:{}不存在", code);
        return pointSendTypeEnum.getName();
    }
}
